<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<style type="text/css">
.dateWidth1{
   width:195px;
}
.selectWidth2{
   width:205px;
}
</style>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">项目贷款基本情况</div>
<table class="t_css" width="100%" border="0" cellpadding="0" id="dkqk" cellspacing="1">
	<tr>
		<td  width="135" align="right">单位名称：</td>
		<td  colspan="5">
			<span id="orgName"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/org_name" /></span>
		</td>
	</tr>
	<tr>
		<td  width="135" align="right">项目名称：</td>
		<td  colspan="5">
			<span id="prjName"><x:out select="$xmlData/data/proposal/zh_title" /></span>
		</td>
	</tr>
	<tr>
		<td  align="right"><span class="color_red">*</span>贷款银行：</td>
		<td  colspan="2">
		<input  name="proposal/lending_bank" label="贷款银行" type="text" required class="input_css required "   maxlength="100" value="<x:out select="$xmlData/data/proposal/lending_bank" />"/>
		</td>
		<td  align="right"><span class="color_red">*</span>银行开户账号：</td>
		<td  colspan="2">
		<input  name="proposal/bank_no" label="银行开户账号" type="text" required class="input_css required "   maxlength="100" value="<x:out select="$xmlData/data/proposal/bank_no" />"/>
		</td>
	</tr>
</table>
<div class="t_bar">贷款情况(单位：万元)</div>
<table  id="tblLendings" cellpadding="0" class="table01" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
			<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center"  width="5%">选择</th>
						<th class="TblHead" align="center"  width="5%">序号</th>
						<th class="TblHead" align="center"  width="13%">合同号码</th> 
				        <th class="TblHead" align="center"  width="13%">贷款日期</th> 
						<th class="TblHead" align="center"  width="13%">到期日期</th> 
						<th class="TblHead" align="center"  width="13%">贷款额度</th> 
						<th class="TblHead" align="center"  width="13%">贷款利率%</th> 
						<th class="TblHead" align="center"  width="13%">已还款金额</th> 
						<th class="TblHead" align="center"  width="12%">已付利息</th> 
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none">
						<td align="center">&nbsp;
							<input type="radio" class="radiobutton" name="sblLendings" >
						</td>
						<td align="center">&nbsp;
							<span name="lendings|lending[0]@seq_no" >[index]</span> 
						</td>
						<td>
							<input type="text" name="lendings|lending[0]|contract_no"  class=" input_text required" maxlength="50" style="width:80%" label="合同号码"/>
						</td>
						<td>
							<input id="start_date[0]" name="lendings|lending[0]|start_date" value="" style="width:80px" class="input_text required date  dateCompare:end_date[0] color_gray" readOnly label="贷款日期" />
						</td> 
						<td>
							<input id="end_date[0]" name="lendings|lending[0]|end_date" value="" style="width:80px" class="input_text required date  color_gray" readOnly label="到期日期" />
						</td> 
						<td>
							<input type="text" name="lendings|lending[0]|loan_commitment" label="贷款额度" id="loan_commitment[0]" onchange="ledningVal();" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" style="width:80%" class="input_text required valueGreatEqual:loan_commitment[0]:repayment[0]" />
						</td> 
						<td>
							<input type="text" name="lendings|lending[0]|loan_rate"  label="贷款利率" onfocus="InitInput.setNumber(this,7,2,2)" style="text-align:right;width:80%" class=" input_text required" />
						</td> 
						<td>
							<input type="text" name="lendings|lending[0]|repayment"  label="已还款金额" id="repayment[0]" onchange="ledningVal();" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" class=" input_text required" />
						</td> 
						<td>
							<input type="text" name="lendings|lending[0]|interest"  label="已付利息" onchange="ledningVal();" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" class=" input_text required" />
						</td> 
					</tr>
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/lendings/lending" var="lending">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr >
						<td align="center">&nbsp;
							<input type="radio" class="radiobutton" name="sblLendings" >
						</td>
						<td align="center">&nbsp;
							<span name="lendings/lending[${flag}${index}]@seq_no" ><x:out select="$lending/@seq_no"/></span> 
						</td>
						<td>
							<input type="text" name="lendings/lending[${flag}${index}]/contract_no"   style="width:80%"   class=" input_text required" value="<x:out select="$lending/contract_no"/>" label="合同号码" maxlength="50"/>
						</td>
						<td >
							<input id="start_date${flag}${index}" name="lendings/lending[${flag}${index}]/start_date" value="<x:out select='$lending/start_date' />" class="input_text required date dateCompare:end_date${flag}${index} color_gray" readOnly label="贷款日期" style="width:80px"/>
						</td> 
						<td >
							<input id="end_date${flag}${index}" name="lendings/lending[${flag}${index}]/end_date" value="<x:out select='$lending/end_date' />" class="input_text required date color_gray" readOnly label="到期日期" style="width:80px"/>
						</td> 
						<td >
							<input type="text" name="lendings/lending[${flag}${index}]/loan_commitment" id="loan_commitment${flag}${index}" onchange="ledningVal();" style="text-align:right;width:80%" onfocus="InitInput.setNumber(this,7,4,2)"  class=" input_text required valueGreatEqual:loan_commitment${flag}${index}:repayment${flag}${index}" value="<x:out select="$lending/loan_commitment"/>" label="贷款额度" />
						</td> 
						<td >
							<input type="text" name="lendings/lending[${flag}${index}]/loan_rate"  onfocus="InitInput.setNumber(this,7,2,2)"   label="贷款利率" style="text-align:right;width:80%"  class=" input_text required" value="<x:out select="$lending/loan_rate" />"/>
						</td> 
						<td >
							<input type="text" name="lendings/lending[${flag}${index}]/repayment" id="repayment${flag}${index}" onchange="ledningVal();" onfocus="InitInput.setNumber(this,7,4,2)" label="已还款金额"  style="text-align:right;width:80%"  class=" input_text required" value="<x:out select="$lending/repayment" />"/>
						</td> 
						<td >
							<input type="text" name="lendings/lending[${flag}${index}]/interest" onchange="ledningVal();" onfocus="InitInput.setNumber(this,7,4,2)" label="已付利息"  style="text-align:right;width:80%"  class=" input_text required" value="<x:out select="$lending/interest" />"/>
						</td> 
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
					<script type="text/javascript">
						showAllDateTag('tblLendings');
					</script>
				</tbody>
					</table>
					<table   cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;" id="dkqk1">
					<tr >
					<td colspan="3" width="23%" align="center">合计</td>
					<td width="13%" align="center">\</td>
					<td width="13%" align="center">\</td>
					<td width="13%"><input name="lendings/loan_commitment" id="loan_commitment" value="<x:out select="$xmlData/data/lendings/loan_commitment" />" disabled class=" input_text gray" label="贷款额度合计" style="text-align:right;width:80%" /></td>
					<td width="13%" align="center">\</td>
					<td width="13%"><input name="lendings/repayment" id="repayment" value="<x:out select="$xmlData/data/lendings/repayment" />" disabled class=" input_text gray" label="已还款金额合计" style="text-align:right;width:80%" /></td>
					<td width="12%"><input name="lendings/interest" id="interest" value="<x:out select="$xmlData/data/lendings/interest" />" disabled class=" input_text gray" label="已付利息合计" style="text-align:right;width:80%" /></td>
					</tr>
					<tr>
					<td colspan="3" align="right"><span class="color_red">*</span>申请贷款贴息金额：</td>
					<td colspan="6" ><input type="text"  name="lendings/dktxje" class="required" label="申请贷款贴息金额" value="<x:out select="$xmlData/data/lendings/dktxje" />" onfocus="InitInput.setNumber(this,9,4,2)" /></td>
					</tr>
                   </table>
					<table width="98%" align="center">
					<tr ><td>
					<input class="button" name="cmdAddbefore" type=button value="添加" onclick="addNewRow('tblLendings');showAllDateTag('tblLendings');try{top.resizeFrame();}catch(e){};ledningVal();">
					<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev('tblLendings','sblLendings')">
					<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext('tblLendings','sblLendings')">
					<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('tblLendings','贷款情况');ledningVal();">
					</td></tr>
	</table>
	
	<script type="text/javascript">
	function ledningVal(){
	 var loan_commitment=0;
	 var repayment = 0;
	 var interest = 0;
	 $("#tblLendings").find("input[name$='loan_commitment']").each(function() {
		 if ($.isNumeric($(this).val())) {
		 loan_commitment = parseFloat(loan_commitment) + parseFloat($(this).val());
		 }
	 });
	 $("#tblLendings").find("input[name$='repayment']").each(function() {
		 if ($.isNumeric($(this).val())) {
		 repayment = parseFloat(repayment) + parseFloat($(this).val());
		 }
	 });
	 $("#tblLendings").find("input[name$='interest']").each(function() {
		 if ($.isNumeric($(this).val())) {
		 interest = parseFloat(interest) + parseFloat($(this).val());
		 }
	 });
	 loan_commitment = ((parseFloat(loan_commitment)*10000)/10000).toFixed(4);
	 repayment = ((parseFloat(repayment)*10000)/10000).toFixed(4);
	 interest = ((parseFloat(interest)*10000)/10000).toFixed(4);
	 
	 $("#loan_commitment").val(formatNumberAutoOther(loan_commitment+"", 7, 4, 2));
	 $("#repayment").val(formatNumberAutoOther(repayment+"", 7, 4, 2));
	 $("#interest").val(formatNumberAutoOther(interest+"", 7, 4, 2)); 
	}
	</script>
	
	

